﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Commission.Chart
{
    public class MyOrgNode : Whidsoft.WebControls.OrgNode 
    {
        //public string Text ; 
        public string Name;
        public string Role;
        public string Amount;

        public string UserName;
        public string CustomerType;
        public int LeftPoint;
        public int RightPoint;
        public string PointString
        {
            get
            {
                return LeftPoint.ToString() + " / " + RightPoint.ToString();
            }
        }

        public override string OrgNodeHtml()
        {
            this.Name = this.Text;

            string str = "<table border=0 bgcolor='#f0f8ff'>";
            str += "<tr>";

            /*
            str += "<td>";
            str += "<img src='" + this.ImageUrl + "'>";
            str += "</td>";
             */

            str += "<td>";
            str += "<table align=top width=116 border=2 bordercolor= " + GetColor() + " cellspacing=0 style='border-collapse:collapse;'>";
            str += "    <tr><td align=center>&nbsp;" + this.UserName + "</td></tr>";
            str += "    <tr bgcolor=white><td align=center><div style='font-size:13px'>&nbsp;<a href='" + this.NavigateUrl + "' title='Đi tới hội viên'>" + this.Name + "</a></div></td></tr>";
            str += "    <tr><td align=center>&nbsp;" + this.CustomerType + "</td></tr>";
            str += "    <tr bgcolor=white><td >&nbsp;" + this.Amount + "</td></tr>";
            str += "    <tr><td align=center>&nbsp;" + PointString + " </td></tr>";
            str += "</table>";
            str += "</td>";

            

            str += "</tr></table>";


            return str;
        }

        static int ImageRnd;
        /// <summary>
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public string GetImageFile(string ID)
        {

            if (ImageRnd > 13) //ﾎﾒｵﾄﾄｿﾂｼﾖｻﾓﾐ13ｸｼ
                ImageRnd = 0;

            string src = "images/" + ImageRnd + ".gif";

            ImageRnd++;
            return src;
        }

        public string GetColor()
        {
            string color = "";
            
            if ("BP".Equals(this.CustomerType))
            {
                color = "MediumPurple";
            }
            else if ("NP".Equals(this.CustomerType) || "100F".Equals(this.CustomerType))
            {
                color = "black";
            }
            else if ("VP150".Equals(this.CustomerType) 
                || "VP".Equals(this.CustomerType) || "300F".Equals(this.CustomerType))
            {
                color = "orange";
            }
            else if ("AP700".Equals(this.CustomerType) || "AP".Equals(this.CustomerType)
                || "1000F".Equals(this.CustomerType))
            {
                color = "red";
            }

            return color;
        }
    }
}